package com.zt.springcloud;

import com.zt.springcloud.entity.Address;
import com.zt.springcloud.entity.Role;
import com.zt.springcloud.entity.User;
import com.zt.springcloud.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * @author RedReins
 * @version 1.0
 * @description: TODO
 * @date 2021/8/28 17:05
 */
@FeignClient(contextId = "RemoteUserService",value = "cloud-system",fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public User getUserInfo(@PathVariable("username") String username);

    /**
     * 通过用户名查询用户角色
     *
     * @param id 用户id
     * @return 结果
     */
    @GetMapping("/user/roles/{id}")
    public Set<Role> getRolesInfo(@PathVariable("id") Long id);

    /*
     * 添加用户地址
     * */
    @RequestMapping(value = "/user/addAddress",method = RequestMethod.POST)
    public Integer addUserAddress(@RequestBody(required = false) Address address);

    /*
     * 查询用户地址
     * */
    @RequestMapping(value = "/user/getUserAddress/",method = RequestMethod.GET)
    public List<Address> getAddressInfo(@RequestParam("userid") Long userid);

    /*
     * 更新用户地址
     * */
    @RequestMapping(value = "/user/updateAddress",method = RequestMethod.POST)
    public Integer updateAddressInfo(@RequestBody Address address);
}
